package mypackage3;

import java.util.ArrayList;

public class PhonePractice {
    public static void main(String[] args) {
        //将手机价格大于3000的集合进行返回
        ArrayList<Phone> list=new ArrayList<>();
        Phone p1=new Phone("小米",1999);
        Phone p2=new Phone("华为",9999);
        Phone p3=new Phone("苹果",5999);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        ArrayList<Phone> result=getPhoneInfo(list,3000);
        for (int i = 0; i < result.size(); i++) {
            System.out.println("手机的品牌是:"+result.get(i).getBrand()+", "+
                    "手机的价格是:"+result.get(i).getPrice()
                    );
        }
    }
    public static ArrayList<Phone> getPhoneInfo(ArrayList<Phone> list,int money){
        ArrayList<Phone> result=new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getPrice()>money){
                result.add(list.get(i));
            }
        }
        return result;
    }
}
